import config from "@/config"
import http from "@/utils/request"

export default {
  pager: {
    url: `${config.API_URL}/admin/v1/project/pager`,
    name: "分页列表",
    get: function (params) {
      return http.get(this.url, params);
    }
  },
  create: {
    url: `${config.API_URL}/admin/v1/project/create`,
    name: "新增",
    post: function (data) {
      return http.post(this.url, data);
    }
  },
  detail: {
    url: `${config.API_URL}/admin/v1/project/:id/detail`, // TODO 替换为：serial
    name: "查看详情",
    get: function (id) {
      const uri = this.url.replace(':id', id);
      return http.get(uri);
    },
    delete: function (id) {
      const uri = this.url.replace(':id', id); // TODO 替换为：serial
      return http.delete(uri);
    }
  },
  list: {
    url: `${config.API_URL}/admin/v1/project/list`,
    name: "项目简表",
    get: function (params = {}) {
      return http.get(this.url, params);
    }
  },

  /**
   * 项目班组
   */
  team: {
    create: {
      url: `${config.API_URL}/admin/v1/project/:id/team/create`,
      name: "新增",
      post: function (id, data) {
        const uri = this.url.replace(':id', id);
        return http.post(uri, data);
      }
    },
    list: {
      url: `${config.API_URL}/admin/v1/project/:id/team/list`,
      name: "班组列表",
      get: function (id) {
        const uri = this.url.replace(':id', id);
        return http.get(uri);
      }
    },
    detail: {
      url: `${config.API_URL}/admin/v1/project/:id/team/:tid/detail`,
      name: "班组列表",
      delete: function (id, tid) {
        const uri = this.url.replace(':id', id).replace(':tid', tid);
        return http.delete(uri);
      }
    }
  }
}
